import { defineStore } from "pinia";
import { ref } from "vue";
import { userGetInfoService } from "@/api/user";
export const useUserStore = defineStore(
  "big-user",
  () => {
    const token = ref("");
    const user = ref({});
    const setToken = (newToken) => {
      token.value = newToken;
    };
    const getUserInfo = async () => {
      const {
        data: { data },
      } = await userGetInfoService();
      user.value = data;
    };
    const setUser = (obj) => {
      user.value = obj;
    };
    const removeToken = () => {
      token.value = "";
    };
    return {
      token,
      setToken,
      removeToken,
      getUserInfo,
      user,
      setUser,
    };
  },
  { persist: true }
);
